<script>
$(document).ready(function() {
    //prepare the dialog
	
    $( "#thanhcong_ngaynghi" ).dialog({
		title: "Thông báo",
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 500
            },
        hide: {
            effect: "blind",
            duration: 500
            },
        modal: true,
		buttons: {
			 "Ok": function() {
				location.reload();
				 $('#thanhcong_ngaynghi').dialog('close');
			}
		 }
        });	
		
	$(".close_addservice").click(function(event) {
				$('#dialogModal').dialog('close');
			});
    });
	
	var specialKeys = new Array();
	specialKeys.push(8); //Backspace
	function IsNumeric(e) {
		var keyCode = e.which ? e.which : e.keyCode
		var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
		document.getElementById("error").style.display = ret ? "none" : "inline";
		return ret;
	}
	
</script>

	<?php echo $this->Form->create('NgayNghi',array('controller'=>'ngaynghis','action'=>'add',$users['User']['id'])); ?>
		<div class="row">
			<label>Nhân viên</label>
			<?php echo $users['User']['name'];?>
		</div>
		<div class="row">
			<label>Số ngày nghỉ</label>
			<?php echo $this->Form->input('count',array('label'=>false,'type'=>'text' ,'id'=>'text1','style'=>'max-width:256px;','div'=>false,'onkeypress'=>'return IsNumeric(event);','onpaste'=>'return false;','ondrop'=>'return false;'));?>
			<span id="error" style="color: Red; display: none">* Chỉ nhập số</span>
		</div>
		<div class="row">
			<label>Lý do nghỉ</label>
			<?php  echo $this->Form->input('reason',array('label'=>false,'div'=>false));?>
		</div>		
		<div class="btn-dialog">
			
			<?php 
			echo $this->Js->submit('OK', array(  //create 'ajax' save button
				'update' => '#contentWrap','div'=>false  //id of DOM element to update with selector
				));
			if (false != $saved){ //will only be true if saved OK in controller from ajax save above
				echo "<script>
					$('#thanhcong_ngaynghi').dialog('open');  //open containing dialog 
				</script>";
				}
			echo $this->Form->end();
			echo $this->Js->writeBuffer();
			?>

			<input type="button" value="Cancel" class="close_addservice">
		</div>

<div id="thanhcong_ngaynghi" title="Thông báo">
<p align="center">Đã thêm ngày nghỉ thành công</p>
</div>
